<template>
  <div id="Allocation">
    <v-detail
      :detailData="inputData"
      :inputConfig="inputConfig"
      :rules="rules"
      ref="input"
    ></v-detail>
  </div>
</template>

<script>
import detail from "commons/Detail";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "Allocation",
  mixins: [baseMixin],
  props: {
    inputData: {
      type: Object,
    },
  },
  data() {
    //自定义验证规则
    const numValidate = (rule, value, callback) => {
      let reg = /^\+?[0-9]\d*$/; //大于零的正整数
      if (!reg.test(value)) {
        this.$message.error(this.$t('app.inputGreaterZeroNumberPlease'));
        this.inputData[rule.field] = 0;
        callback(new Error());
      } else {
        callback();
      }
    };
    return {
      inputConfig: [
        [
          {
            type: "checkbox",
            label: this.$t('outbound.createassignments'),
            props: "createassignments",
          },
          {
            type: "input",
            label: this.$t('outbound.zonebreak'),
            props: "zonebreak",
          },
        ],
        [
          {
            type: "input",
            label: this.$t('outbound.maxpicklines'),
            props: "maxpicklines",
          },
          {
            type: "input",
            label: this.$t('outbound.maxpickingcontainers'),
            props: "maxpickingcontainers",
          },
        ],
        [
          {
            type: "input",
            label: this.$t('outbound.labormaxcasecnt'),
            props: "labormaxcasecnt",
          },
          {
            type: "input",
            label: this.$t("config.maxVolume"),
            props: "labormaxcube",
          },
        ],
        [
          {
            type: "input",
            label: this.$t("config.maxWeight"),
            props: "labormaxweight",
          },
        ],
      ],
      rules: {
        maxpicklines: [
          {
            required: true,
            message: this.$inputPlease("config.maxPickLine"),
            trigger: "blur",
            validator: numValidate,
          },
        ],
        maxpickingcontainers: [
          {
            required: true,
            message: this.$inputPlease("config.maxPickCarton"),
            trigger: "blur",
            validator: numValidate,
          },
        ],
        maxcasecnt: [
          {
            required: true,
            message: this.$inputPlease("config.maxCarton"),
            trigger: "blur",
            validator: numValidate,
          },
        ],
        maxcube: [
          {
            required: true,
            message: this.$inputPlease("config.maxVolume"),
            trigger: "blur",
            validator: numValidate,
          },
        ],
        labormaxweight: [
          {
            required: true,
            message: this.$inputPlease("config.maxWeight"),
            trigger: "blur",
            validator: numValidate,
          },
        ],
      },
    };
  },
  methods: {},
  mounted() {},
  components: {
    "v-detail": detail,
  },
};
</script>

<style scoped></style>
